package com.xlh.enums.course;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 课程预置枚举
 * <p>
 * Created by lx on 2019/3/2.
 */
@Getter
@AllArgsConstructor
public enum CourseSharedEnum {

    ALL(1, "教师及其他角色已共享"),
    PRESET(2, "只有预置共享"),
    OTHER(3, "只有教师共享");

    private int code;

    private String message;

    public static CourseSharedEnum getByCode(int code) {
        for (CourseSharedEnum courseSharedEnum : CourseSharedEnum.values()) {
            if (Objects.equals(courseSharedEnum.getCode(), code)) {
                return courseSharedEnum;
            }
        }
        return null;
    }

    public static String getMessageByCode(int code) {
        CourseSharedEnum courseSharedEnum = getByCode(code);
        return courseSharedEnum == null ? null : courseSharedEnum.getMessage();
    }

}
